<template>
    <div name='pager_add'>
          <link rel="stylesheet" href="../../static/css/b.css">
              <link href="../../static/css/style.default.css" rel="stylesheet">
        <body>
            <Header></Header>
            <section>
                <div class="mainwrapper">

                    <!-- 侧边栏 -->
                    <Sidebar></Sidebar>
                    <!-- /侧边栏 -->

                    <div class="mainpanel">
                        <div class="contentpanel">
                            <div class="row row-stat">

              <div class="viewFrameWork-body">
                <!-- loading -->
                <div class="spinner-wrapper hidden" id="spinnerLoading">
                    <div class="spinner">
                        <div class="rect1"></div>
                        <div class="rect2"></div>
                        <div class="rect3"></div>
                        <div class="rect4"></div>
                        <div class="rect5"></div>
                    </div>
                </div>

                <div class="body-wrapper">
                    <div class="body-content">
                        <div class="cont-r">
            <div role="tabpanel" class="tab-area tab-col4">
                <ul class="nav nav-tabs" role="tablist">
                    <li role="presentation" class="active step1">
                        <a href="#createTest1" aria-controls="create1" role="tab" data-toggle="tab">
                            第一步:创建试卷
                        </a>
                    </li>
                    <li role="presentation" class="step3">
                        <a href="#createTest3" aria-controls="create3" role="tab" data-toggle="">
                            第二步:添加试题
                        </a>
                    </li>
                    <li role="presentation">
                        <a href="#createTest4" aria-controls="create4" role="tab" data-toggle="">
                            第三步:发布考试
                        </a>
                    </li>
                </ul>

               
                    <div class="tab-content">
                        <div role="tabpanel" class="tab-pane active" id="createTest1">
                            <div class="create-test-area new-test-aera clearfix">
                           
                                <div id="stepTop">
                                    <div class="create-test-box guide col-xs-10 col-md-offset-1 animate" step="2">
                                        <h3>
                                            <input name="newpaper" type="radio" v-model="is_paper" checked="" class="new-test">
                                            创建新试卷
                                        </h3>
                                        <div class="ctb-row">
                                            试卷名称：
                                            <input type="text" v-model="exam_name" placeholder="请输入试卷名称" maxlength="30" value="">
                                            <span class="f-style4">*</span>
                                        </div>
                                         <div class="ctb-row">
                                            试卷题数：
                                            <input type="text" v-model="exam_count" placeholder="请输入试卷题数" maxlength="30" value="">
                                            
                                        </div>
                                        <div class="ctb-row">
                                            试卷分类：
                                          
                                        <div class="inline-block relative w-64"> 
                                                    <select  v-model="text_mold_all_id" class="block appearance-none w-full bg-white border border-gray-400 hover:border-gray-500 px-4 py-2 pr-8 rounded shadow leading-tight focus:outline-none focus:shadow-outline">
                                                            <option v-for="i in text_mold_all" :key="i.id" :value="i.id" >{{i.test_name}}</option>
                                                    </select>
                                        </div>
                                        </div>
                    <!--原第二步 组卷方式 -->
                                       

                                        <input type="text" class="hidden" name="add_style">

                                        <div class="limitquestiontime">
                                            答题时长：
                                            <span class="limit_t_btn limit_all_paper" data-value="0">整卷限制时长</span>
                                            <input type="hidden" id="limitQT" value="0" name="limitQtime">
                                        </div>

                                        <div class="btn-div">
                                            <button @click="submin" class="btn btn-primary btn-step1 guide-btn" >下一步</button>
                                        </div>
                                    </div>
                                </div>
                       
                            
                            </div>
                            <div class="create-test-area pick-test-aera clearfix" hidden="" style="display: none;">
                                <div class="create-test-bar create-test-bar2 col-md-10 col-md-offset-1 animate">
                                    <input name="" type="radio" value="" class="new-test">
                                    创建新试卷
                                </div>
                                <div class="create-test-box col-md-10 col-md-offset-1 animate">
                                    <h3>
                                        <input name="" type="radio" value="" checked="checked">从试卷库中选择一张试卷
                                    </h3>
                              
                                    <div class="btn-div">
                                        <input type="hidden" class="" name="paper_set_num" value="1">
                                        <input type="hidden" class="" name="paper_info_id" value="">
                                        <button  id="jumpToExam" data-dismiss="modal" class="btn btn-primary">
                                            下一步
                                        </button>
                                    </div>
                                </div>
                            </div> 
                        </div>

                        
                        <div role="tabpanel" class="tab-pane" id="createTest3">
                            <div class="input-questions-area clearfix pick-random" style="display: none;">
                                试卷状态：
                                <select name="paper_status">
                                    <option value="0" selected="">正常</option>
                                    <option value="1">禁用</option>
                                </select>
                                试卷总分：
                                <input type="text" style="width:50px;" name="total_score" value="100">
                                <div class="topSelDiv">
                                    <div class="title">题型设置</div>
                                    <ul class="addIconUl">
                                        <li class="addDanxuanLi" name="1" title="单选"><i class="glyphicon glyphicon-plus-sign"></i> 单选</li>
                                        <li class="addDuoxuanLi" name="2" title="多选"><i class="glyphicon glyphicon-plus-sign"></i> 多选</li>
                                        <li class="addPanduanLi" name="3" title="判断"><i class="glyphicon glyphicon-plus-sign"></i> 判断</li>
                                        <li class="addTiankongLi" name="4" title="填空"><i class="glyphicon glyphicon-plus-sign"></i> 填空</li>
                                        <li class="addWendaLi" name="5" title="问答"><i class="glyphicon glyphicon-plus-sign"></i> 问答</li>
                                    </ul>
                                </div>
                                <!--选题组卷-->
                                <table class="table table-condensed table-hover customerTab tab1">
                                    <thead>
                                    <tr>
                                        <th>排序</th>
                                        <th>题型</th>
                                        <th>数量</th>
                                        <th class="contentTh">题型标题</th>
                                        <th>每题分数</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody class="typeTabBody">
                                    </tbody>
                                </table>
                                <!--抽题组卷-->
                                <table class="table table-condensed table-hover customerTab tab2" style="display: none;">
                                    <thead>
                                    <tr>
                                        <th>排序</th>
                                        <th>题型</th>
                                        <th>数量</th>
                                        <th class="contentTh">题型标题</th>
                                        <th>每题分数</th>
                                        <th>试题分类</th>
                                        <th>抽取数量</th>
                                    </tr>
                                    </thead>
                                    <tbody class="typeTabBody">
                                    </tbody>
                                </table>
                                <!--随机组卷-->
                                <table class="table table-condensed table-hover customerTab tab3" style="display: none;">
                                    <thead>
                                    <tr>
                                        <th>排序</th>
                                        <th>题型</th>
                                        <th>数量</th>
                                        <th class="contentTh">题型标题</th>
                                        <th>每题分数</th>
                                        <th>试题分类</th>
                                        <th>抽取数量</th>
                                    </tr>
                                    </thead>
                                    <tbody class="typeTabBody">
                                    </tbody>
                                </table>
                                <input type="hidden" class="" name="paper_set_num" value="">
                                <p class="buttonP">
                                    <a class="button" href="#" id="previewBtn">预览</a>
                                    <a class="button" href="#" id="saveBtn">保存</a>
                                    <a class="button" href="#" id="downloadBtn">下载</a>
                                </p>
                                <!-- 3-2结束 -->
                            </div>
                            <div role="tabpanel" class="tab-pane" id="createTest4"></div>
                        </div>
                    </div>
               
            </div>
        </div>
                    </div>
                </div>
            </div>






                            </div><!-- row -->
                        </div>
                        <!-- contentpanel -->
                    </div>
                    <!-- mainpanel -->
                </div>
                <!-- mainwrapper -->
            </section>
 
        </body>
    </div>
    
</template>
<script>
import axios from 'axios'
export default {
    name:'Paper_add_new',
    data() {
        return {
            is_paper:'',
            text_mold_all:[],
            exam_name:'',
            text_mold_all_id:0,
            exam_count:'',
        }
    },    
    mounted(){
        axios({
                url:this.$api+'/user/parer_new_all/?token='+ window.localStorage.getItem('token'),
                method:'get',
            }).then(res=>{
              console.log(res)
                if(res.data.code==200){
                      this.text_mold_all=res.data.text_mold_all
                      
                }
            })
    },

    methods: {
        submin(){
            axios({
                url:this.$api+'/user/add_final_exam/',
                method:'post',
                data:{'token':window.localStorage.getItem('token'),'exam_name':this.exam_name,'text_mold_all_id':this.text_mold_all_id,'exam_content':this.exam_count}
            }).then(res=>{
              console.log(res)
                if(res.data.code==200){
                    window.localStorage.setItem('exam_id',res.data.exam_id)
                    this.$router.push({path: '/paper_add'})
                    
                   alert('成功')
                }else{
                 alert('失败')
                }
            })
        }
    },

}
</script>
